﻿layui.use(['layer', 'form', 'laydate', 'element']);
//分页
function page(pages, pageindex) {
    layui.use(['laypage', 'layer'], function () {
        var laypage = layui.laypage
            , layer = layui.layer;

        laypage({
            cont: 'page'
            , pages: pages
            , curr: pageindex
            , groups: 8
            //, hash: 'pageindex'
            , skip: true
            , jump: function (obj, first) {
                if (first == undefined || pages == -1) {
                    var pageindex = pages == -1 ? 1 : obj.curr;
                    var parames = new Array();
                    parames.push({ name: "pageindex", value: pageindex });
                    var div = document.getElementById("ss");
                    var input = div.getElementsByTagName("input");
                    var select = div.getElementsByTagName("select");
                    for (var i = 0; i < input.length; i++) {
                        parames.push({ name: input[i].name, value: input[i].value });
                    }
                    for (var i = 0; i < select.length; i++) {
                        parames.push({ name: select[i].name, value: select[i].value });
                    }
                    //console.log(parames);
                    post(window.location.href, parames);
                    return false;
                }
            }
        });
    });
}

/*
*功能： 模拟form表单的提交
*参数： URL 跳转地址 PARAMTERS 参数 
*/
function post(URL, PARAMTERS) {
    //创建form表单
    var temp_form = document.createElement("form");
    temp_form.action = URL;
    //如需打开新窗口，form的target属性要设置为'_blank'
    temp_form.target = "_self";
    temp_form.method = "post";
    temp_form.style.display = "none";
    //添加参数
    for (var item in PARAMTERS) {
        var opt = document.createElement("textarea");
        opt.name = PARAMTERS[item].name;
        opt.value = PARAMTERS[item].value;
        temp_form.appendChild(opt);
    }
    document.body.appendChild(temp_form);
    //提交数据
    temp_form.submit();
}
//弹层新URL
function Showiframe(title, url) {
    layer.open({
        type: 2,
        title: title,
        shadeClose: true,
        maxmin: true, //开启最大化最小化按钮
        shade: 0.8,
        area: ['88%', '88%'],
        content: url
    });
}
//显示图片
function showimg(gid) {
    layer.ready(function () {
        layer.photos({
            photos: '#' + gid
            , anim: 5
        });
    });
}
